﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mamnontuoitho7.AppCode;

namespace mamnontuoitho7.backend
{
    public partial class ClipCreate : System.Web.UI.Page
    {
        VideoClip _videoClip = new VideoClip();
        protected void Page_Load(object sender, EventArgs e)
        {
            //Check Role Admin
            if (Session["memberID"].ToString() != "" && (ConstantClass.permissionArticle).IndexOf(Session["role"].ToString() + ",") != -1)
            { }
            else
            {
                Response.Redirect(ConstantClass._errorLoginPage);
            }
        }

        protected void btnClipCreate_Click(object sender, EventArgs e)
        {
            try
            {
                bool check = _videoClip.VideoCreateBySP("3", Session["memberID"].ToString(), txtTitleClip.Text.Trim(), txtDescription.Text.Trim(), "0", "1", Session["username"].ToString(), _videoClip.CutVideoURL(txtURLClip.Text.Trim()));
                txtTitleClip.Text = "";
                txtURLClip.Text = "";
                txtDescription.Text = "";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Response.Redirect(ConstantClass._errorAdminPage);
            }
            String script1 = "<script language=JavaScript>alert('Tạo Clip thành công'); window.location = '../backend/ClipCreate.aspx';</script>";
            Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", script1);
        }
    }
}